<?php get_header(); ?>
<div id="main">
<div id="main2">
	
	<?php
	$oStep_table_html =  "
	    <table cellspacing='0' cellpadding='3' class='oSteps' border='1'>
		<tr>
	 	<td class='[s1]'><span>1</span>Payment &amp; Delivery</td>
	 	<td class='[s2]'><span>2</span>Address</td>
	 	<td class='[s3]'><span>3</span>Summary</td>
	 	<td class='[s4]'><span>4</span>Finished!</td>
		</tr>
		</table>
		";
	
	// show the shopping cart
	if($_GET[showCart] == '1'){
			
		$CART = show_cart();
				
		echo "		
		<div class='padding clearfix'>		
		<h2>Your Shopping Cart</h2>
		";
		if($CART[status] == 'filled'){	
			echo "
			<form class='order_table' action='?showCart=1' style='margin-top: 0px;' method='post'>
			";
		}
		echo "		
		<table class='order_table' border='0'>
			<thead>
				<tr>
					<th>&nbsp;</th><th>Article</th>
					<th>Amount</th>
					<th>Unit price</th><th colspan='2'>Total</th><th>Remove</th>
				</tr>
			</thead>
		";	
		$child_theme 	= get_option('wps_child_theme');
		$thumb_path 	= "wp-content/themes/{$child_theme}/images/";

		$l_mode		= get_option('wps_l_mode');
		
		if($CART[status] == 'filled'){
			foreach($CART[content] as $v){
			
				$details 	= explode("|",$v);
				$pic_path	= $thumb_path . $details[6];
				$th_height	= thumbs_height($pic_path,get_option('wps_cart_thumb_width'));
			
				echo "
					<tr>
						<td><span class='c_img_wrap'><span><img src='{$thumb_path}{$details[6]}' width='";echo get_option('wps_cart_thumb_width');
						echo "' height='$th_height' alt='$details[2]' /></span></span></td>				
						<td>$details[2]</td><td>";
						
						// we dont show amount input field if licensing mode is on SIMPLE
						if($l_mode == 'SIMPLE'){
							echo "1";
						}
						else {
							echo "<input class='text' type='text'  name='amount_{$details[0]}' size='3' maxlength='3' value='$details[1]'/>";
						}
						
								

						echo "
						</td><td>$details[3] "; echo get_option('wps_currency_code'); echo "</td>
						<td>$details[4]</td>
						<td >";echo get_option('wps_currency_code');echo"</td>
						<td><input type='checkbox' name='rm_{$details[0]}' /></td>
					</tr>					
				";
			}
		}
		else {
				echo "
					<tr>
						<td colspan='6'><h4 class='error'>Your Shopping Cart is empty!</h4></td>
						<td><a class='button cont_shop' href='$_SESSION[cPage]'>Continue shopping</a></td>
					</tr>
					";
		
		}
		
			
		if($CART[status] == 'filled'){	
			echo "
				<tr class='sums'>
					<td colspan='4' style='text-align:right;'>
						<b>Subtotal:</b>
						";
						
						$tax_info_disable = get_option('wps_tax_info_disable'); 	
						if($tax_info_disable != true){	
						echo "
						<br/>
						<small>
							incl.
							"; 
							echo get_option('wps_tax_percentage'); 
							echo "% "; 
							echo get_option('wps_tax_abbr'); 
							#echo ", excl. <a href='?showTerms=1' class='tooltip' title='";
							#echo get_option('wps_shipping_details');
							#echo "' >Shipping &amp; Handling Costs</a>
						echo "'</small>
						";
						}
					echo "
					</td>
					<td><b>$CART[total_price]</b></td>
					<td><b>";echo get_option('wps_currency_code'); echo "</b></td>
					<td>&nbsp;</td>
				</tr>
			</table>
			
			
			<input  class='button update'  type='submit' name='update' value='Update' />
			</form>
			<a class='button cont_shop' href='$_SESSION[cPage]'>Continue shopping</a>
			<form action='?orderNow=1' style='margin-top: 0px;' method='post'>		
			<input  class='button order'  type='submit' name='order' value='Order now' />
			</form>
			";
		}
		else {
			echo "</table>";
		}
		echo "</div><!-- padding-->";
		
	
	}
	elseif($_GET[orderNow] == '1'){
	
	
		$order_level = what_order_level();
		if($order_level == 2){
			$go = '3&dpchange=1';
		}
		else{
			$go = '2';
		}
	
		
		echo order_step_table($oStep_table_html,1);
		echo "<br/><br/>
		<form class='step1' action='?orderNow={$go}' method='post'>
		
		<h4>Choose delivery option:</h4>";
		
		$d_labels			= array();
		$d_labels[pickup]	= 'I will collect the order myself from the shop';
		$d_labels[post]		= 'I like the order to be delivered by post.';
		$d_labels[download]	= 'After sucessful payment you will receive on this website download links.';

		echo get_delivery_options($d_labels);
		echo "<br/><br/><br/>";


		echo "<h4>Choose payment option:</h4>";
	
		$p_labels			= array();
		$p_labels[paypal]	= 'PayPal';
		$p_labels[transfer]	= 'Bank transfer in advance';
		$p_labels[cash]		= 'Payment at our shop';

		
		echo get_payment_options($p_labels);
		echo "<br/><br/><br/>";		
		echo "
		<h4>I need an invoice:</h4>
		<input class='' type='checkbox' name='invoice_needed' value='1' /> Yes
		";
		echo "<br/><br/><br/>";	
		echo "	
		<input class='button next_step' type='submit' name='step1' value='next Step' />
		</form>
		";
	
	}	
	elseif($_GET[orderNow] == '2'){
		
		process_order();
		
		$feedback = check_address_form();
		
		echo order_step_table($oStep_table_html,2);
		echo "
				<h4 class='step2'>Enter your name &amp; email address:</h4>
				
				$feedback[e_message] <br/><br/>
				<div class='padding clearfix'>
					<form class='step2 clearfix' action='?orderNow=2' method='post'>
					<label>Lastname:</label><input type='text' name='l_name' value='$_POST[l_name]' maxlength='255' /><br/>
					<label>Firstname:</label><input type='text' name='f_name' value='$_POST[f_name]' maxlength='255' /><br/>";
				
				if(invoice_needed() == '1'){				
				echo "
					<label>Street &amp; House no:</label><input type='text' name='street' value='$_POST[street]' maxlength='255' /><br/>
					<label>State/Province:</label>"; 	
					$ct = get_option('wps_shop_country');
					
					if(($ct == 'US') || ($ct == 'AT') || ($ct == 'AU') || ($ct == 'CA') || ($ct == 'DE') || ($ct == 'GB') || ($ct == 'MX') ||
					($ct == 'CH') || ($ct == 'IN') || ($ct == 'CY')){
						include 'wp-content/themes/eGoods/lib/static-info/provinces/'. $ct. '.php';										
					}			
					else {
						echo "<input type='text' name='state' value='$_POST[state]' maxlength='255' /><br>";
					}
					echo "
					<label>Zip:</label><input type='text' name='zip' value='$_POST[zip]' maxlength='255' /><br/>
					<label>Town:</label><input type='text' name='town' value='$_POST[town]' maxlength='255' /><br/>
					<label>Country:</label><input type='text' name='country' value='";
					$land = get_option('wps_shop_country');
					echo get_countries(2,$land);
					echo "' maxlength='255' readonly='readonly' /><br/>";
				}
					echo "
					<label>Email:</label><input type='text' name='email' value='$_POST[email]' maxlength='255' /><br/>	
					<br/><br/><br/>
					
					<h5>Terms & Conditions:</h5>
					<input type='checkbox' name='terms_accepted' /> 
					<a class='tooltip' href='?showTerms=1' target='_blank' title='";echo nl2br(get_option('wps_terms_conditions'));echo "'>I accept the terms & conditions of "; 
					echo get_option('wps_shop_name');
					echo ".</a><br/><br/>	
					<input class='button next_step' type='submit' name='step2' value='next Step' />
					</form>
				</div>				
		";
		
		
	}	
	elseif($_GET[orderNow] == '3'){
		
			
		$order 		= process_order(3);
		$CART 		= show_cart();
		$shipping 	= calculate_shipping($order[d_option],$CART[total_price],$CART[total_weight],$CART[total_item_num]);
		$TOTAL_AM	= update_order($CART[total_weight],$shipping,$CART[total_price]);
		
				
		$d_labels			= array();
		$d_labels[pickup]	= 'I will collect the order myself from the shop';
		$d_labels[post]		= 'I like the order to be delivered by post.';
		$d_labels[download]	= 'After sucessful payment you will receive on this website download links.';
	
		$p_labels			= array();
		$p_labels[paypal]	= 'PayPal';
		$p_labels[transfer]	= 'Bank transfer in advance';
		$p_labels[cash]		= 'Payment at our shop';
		
		
		echo order_step_table($oStep_table_html,3);
		echo "<h4 class='step3'>Delivery:</h4>";	
		echo $d_labels["$order[d_option]"];
		echo "<br/><br/><br/><br/><br/><br/>
		
				
		<h4 class='step3'>Address - your data:</h4>
		$order[l_name] $order[f_name]";
		if(invoice_needed() == '1'){
			echo "<br/>$order[street]<br/>
			$order[town], $order[state] $order[zip]<br/> 
			$order[country]<br/>";
		}
		echo "<br/>$order[email]<br/>";
		echo " (<a href='?orderNow=2'>change</a>)<br/><br/><br/><br/><br/><br/>";

		
		echo "<h4 class='step3'>Payment:</h4>";	
		echo $p_labels["$order[p_option]"];
		//echo " (<a href='?orderNow=1'>change</a>)
		
		echo "<br/><br/><br/><br/><br/><br/>";
		
		echo "<h4 class='step3'>Your order:</h4>  (<a href='?showCart=1'>change</a>)<br/><br/>";	
		
			
			echo"
			<table class='order_table' border='1'>
				<thead>
					<tr>
						<th>&nbsp;</th><th>Article</th><th>Amount</th><th>Unit price</th><th>Total</th>
					</tr>
				</thead>
			";	
			
		$child_theme 	= get_option('wps_child_theme');
		$thumb_path 	= "wp-content/themes/{$child_theme}/images/";	
		
			if($CART[status] == 'filled'){
				foreach($CART[content] as $v){
				
					$details 	= explode("|",$v);
					$pic_path	= $thumb_path . $details[6];
					$th_height	= thumbs_height($pic_path,get_option('wps_cart_thumb_width'));
					
				
					echo "
						<tr>
						<td><span class='c_img_wrap'><span><img src='{$thumb_path}{$details[6]}' width='";echo get_option('wps_cart_thumb_width');
						echo "' height='$th_height' alt='$details[2]' /></span></span></td>	
							<td>$details[2]</td>
							<td>$details[1]</td>
							<td>$details[3] "; echo get_option('wps_currency_code'); echo "</td>
							<td>$details[4] "; echo get_option('wps_currency_code'); echo "</td>
						</tr>								
					";
				}
			}
		
			
		if($CART[status] == 'filled'){	
			echo "
	
				<tr class='sum'>
					<td colspan='3' align='right'>
					&nbsp;
					</td>
					<td><b>Subtotal:</b></td>
					<td>$CART[total_price] "; 
					echo get_option('wps_currency_code');
					echo "</td>
				</tr>
				";			
	
				
				echo "
				<tr class='sum'>
							<td colspan='3'>&nbsp;</td><td>&amp; Shipping fee</td>
							<td>$shipping 0.00 "; echo get_option('wps_currency_code'); echo "</td>
				</tr>
				";
				
				
				
				echo "
				<tr class='sum'>
					<td colspan='3' align='right'>&nbsp;
					</td>
					<td>
						<b>Total:</b><br/>";
						
						$tax_info_disable = get_option('wps_tax_info_disable'); 	
						if($tax_info_disable != true){						
								echo "
								<small>
									incl.
									"; 
									echo get_option('wps_tax_percentage'); 
									echo "% "; 
									echo get_option('wps_tax_abbr'); 
									//echo ", excl. <a href='' title='";
									//echo get_option('wps_shipping_details');
									//echo "' >Shipping &amp; Handling Costs</a>
									echo "
								</small>
								";
						}
						
						echo "
						</td>
					<td><span class='total_cart_price'>$TOTAL_AM "; echo get_option('wps_currency_code'); echo "</span></td>
				</tr>
			</table>
			<br/>
			";
		}
		
	
		//echo " (<a href='?orderNow=1'>change</a>)        
		$date_order = date("m.d.y - H:i");  // 4 Germans e.g.
		$date_order = date("F j, Y, g:i a");                 
		
		echo "<br/>
		<form class='order_now' method='post' action='https://www.paypal.com/cgi-bin/webscr' target='_top'>
		<input type='hidden' name='cmd' value='_xclick' />
		<input type='hidden' name='business' value='"; echo get_option('wps_paypal_email'); echo "'/>
		<input type='hidden' name='item_name' value='Your Order - $date_order' />
		<input type='hidden' name='amount' value='$TOTAL_AM' />
		<input type='hidden' name='currency_code' value='";echo get_option('wps_currency_code'); echo "' />
		<input type='hidden' name='quantity' value='1' />
		<input type='hidden' name='custom' value='$_SESSION[cust_id]' />	
		<input type='hidden' name='first_name' value='$order[f_name]' />
		<input type='hidden' name='last_name' value='$order[l_name]' />";
		if(invoice_needed() == '1'){
			echo "
			<input type='hidden' name='address_street' value='$order[street]' />				
			<input type='hidden' name='address_zip' value='$order[zip]' />
			<input type='hidden' name='address_city' value='$order[town]' />
			<input type='hidden' name='address_state' value='$order[state]' />	
			<input type='hidden' name='address_country' value='$order[country]' />
			";
		}
		$child_theme 	= get_option('wps_child_theme');
		echo "
		<input type='hidden' name='no_shipping' value='1' />
				
		<input type='hidden' name='bn'  value='ButtonFactory.PayPal.001' />
		<div class='shopform_btn'>
			<input type='image'  name='add' src='"; echo bloginfo('wpurl'); echo "/wp-content/themes/{$child_theme}/images/pay_now.png'/>
		</div>
		</form>	
		<br/>
		<br/>
		<span class='error order_remark'>Remark: <u>Do not close this browser window</u> until you see the confirmation page - otherwise the order maybe interrupted.</span> 
		";

	}
	elseif($_GET[orderNow] == '4'){
	
			echo "Order is done";
	}
	elseif($_GET[confirm] == '1'){	

		$PDT_DATA 	= pdt_response();
			
		if($PDT_DATA[payment_status] == 'Completed')	// the paypal transaction was successful 
		{
					echo order_step_table($oStep_table_html,4);
					echo ("<h2>Thank you for your purchase!</h2>");
					echo ("<dl class='payment_details'><dt>Payment Details</dt>\n");
					echo ("<dd>Name: $PDT_DATA[firstname] $PDT_DATA[lastname]</dd>\n");
					echo ("<dd>Item: $PDT_DATA[itemname]</dd>\n");
					echo ("<dd>Amount of your order: $PDT_DATA[amount] $PDT_DATA[currency]</dd></dl>\n\n");
					
					echo "
					<h3 class='order_success'>Your transaction has been completed, and a receipt of your purchase has been emailed to you.</h3>
					<h4>What next?</h4>	
					<p>	
						You may log into your account at <a href='https://www.paypal.com'>www.paypal.com</a> to view details of this transaction.<br/>
						You may also track your order using the tracking number you are given in your confirmation email. Simply enter that number in the field under 'Track Your Order' in the sidebar.
					</p>
					<h4>Print your order?</h4>
					<p>
						<a href='wp-content/themes/eGoods/pdf/bills/{$PDT_DATA[pdf_bill]}' target='_blank'>Your bill in pdf format</a>
					</p>
					";
					// delivery option = download? dlinks are shown 
					if($PDT_DATA[d_option] == 'download'){
					
						$_SESSION[dlinks] 	= $PDT_DATA[dlinks];
						$_SESSION[d_option]	= $PDT_DATA[d_option];
						$_SESSION[who]		= $PDT_DATA[who];
					}					
					
					
					// delivery option = pickup? customer needs to know where to pickup 
					if($PDT_DATA[d_option] == 'pickup'){
						$maplink = get_option('wps_google_maps_link');
						echo "
						<h4>You can collect your items at our shop location in:</h4>";
						echo "<p>";
							echo get_option('wps_shop_name');
							echo "<br/>";
							echo get_option('wps_shop_street');
							echo "<br/>";
							echo get_option('wps_shop_province');
							echo "<br/>";
							echo get_option('wps_shop_zip');						
							echo get_option('wps_shop_town');
							echo "<br/>";
							echo get_option('wps_shop_country');
						echo "</p>";
						echo "
						<h4>Your Tracking ID</h4>";
						echo "<p>";
							echo "Please give the following Tracking-ID to the shop assistant when you come to collect your items: ";
							echo "$PDT_DATA[tracking_id]";
						echo "</p>";
						
						if(strlen($maplink) > 5){
						echo "
						<h4>Our location</h4>";
						echo "<p>";
						echo "<a href='$maplink' target='_blank'>Google Maps - How to find us</a>";
						}
						echo "</p>";						
					}
					
					
					
					echo "<h5>Like to continue shopping? <a href='"; echo get_option('home'); echo "'>Click here.</a></h5>
					";			
		}
		elseif($PDT_DATA[payment_status] == 'Pending'){
		
					$prLabel 			= array();
					$prLabel['echeck']	= "Your payment is pending because it was made with an eCheck that has not yet cleared ";
					$prLabel['echeck']	.= "<br/>or you sent money via bank transfer.";
					$prLabel['echeck']	.= "<br/>As soon as the paypal transcation is completed we will process your order.";
		
					echo "<h3 class='order_pending'>We received your order - but PayPal payment is pending.</h3>
					
					<p>Reason: <br/>"; echo $prLabel[$PDT_DATA[pending_reason]];			
					echo "<h5>Like to continue shopping? <a href='"; echo get_option('home'); echo "'>Click here.</a></h5>";					
		}
		else {}
		/*
		else {
					// another case 
					echo "<h3>We received from PayPal the following payment status: $PDT_DATA[payment_status]</h3>
					
					<p>Reason might be: $PDT_DATA[pending_reason]";		
					echo "</p>";
		}
		*/
		
		
		// we need permanent dlinks - PDT is too temporary 	
		if($_SESSION[d_option] == 'download'){
		
		
						$l_mode			= get_option('wps_l_mode');
						$text_addition1	= ($l_mode == 'GIVE_KEYS' ? ' and License Keys' : NULL);
						$text_addition2	= ($l_mode == 'GIVE_KEYS' ? 'Pls. copy your keys immediately and store them at a safe place.' : NULL);
		
						echo "<div class='dlinks'>
						<h5>These are your download links{$text_addition1}:</h5>
						<img src='wp-content/themes/eGoods/images/download_arrow.png' align='left'/><br/>
						";
					
					
						if($l_mode == 'GIVE_KEYS'){
						
								if(isset($_SESSION[keys])){
								
								}
								else {
									$_SESSION[keys]	= array();
									$length			= array();
								}
						}
					
						foreach($_SESSION[dlinks] as $v){
								
							$fname = substr(strrchr($v,'/'),1);
							echo "<a href='$v'><u>$fname</u></a><br/><br/>";		

										if($l_mode == 'GIVE_KEYS'){
										
											$l_check 			= $_SESSION[keys]["$fname"];											
											$length[$fname] 	= strlen($l_check);
											
											if($length[$fname] < 1){
												$_SESSION[keys][$fname] = get_lkeys($fname,$_SESSION[who]);
											}
											$keys = explode("#",$_SESSION[keys][$fname]);
											
											echo "&nbsp;&nbsp License keys: &nbsp;&nbsp ";
											
											foreach($keys as $n){
												echo "$n &nbsp;&nbsp;";
											}
											echo "<hr/><br/>";											
										}	
						}						
						echo "$text_addition2 </div>";			


						#print_r($_SESSION);
		}
		
	
	}
	elseif($_GET[showTerms] == '1'){
	
					echo "<h2>TERMS & CONDITIONS</h2>";	
					echo "<p>";
					echo nl2br(get_option('wps_terms_conditions'));
					echo "</p>";
	}
	elseif($_GET[showMap] == 1){
			
		$maplink = get_option('wps_google_maps_link');
		echo "
		<h2>How to find us</h2>
		<a href='$maplink' target='_blank'>Google-Map-Link</a>
		";
		
	}
	elseif($_GET[checkOrderStatus] == 1){
	
		echo "
		<h2>Status of your order:</h2>";
		$tid = trim($_POST[tid]);
		echo "<p>";
		echo  check_order_status($tid);	
		echo "</p>";
	}
	elseif($_GET[removeDLinks] == '1'){
	
		delete_dlink();
		
	}
	#################################### r later ##########################################
	elseif($_GET[listdirs] == '1'){
		
		#echo find_masterdata_path(2);	

	}
	##################################################################################
	else {
		// this is a "fake cronjob" = whenever default index page is called - the age of dlinks is checked
		delete_dlink();
		
	?>
	
		<div id="featured_holder" class="noprint">
			<div class="outer">
				<?php $my_query1 = new WP_Query('category_name='.get_option('wps_featured').'&showposts=1'); ?>
				<?php while ($my_query1->have_posts()) : $my_query1->the_post(); ?>
				
					<!--  option 1: use a promotional image -->
					<?php if(get_post_meta($post->ID, 'featured_img', true)) { 
						$values = get_post_custom_values("featured_img"); 
						$featured_img = $values[0]; ?>
						
							<div class="inner opt1 clearfix">				
								<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
									<img src="<?php bloginfo('wpurl'); ?>/wp-content/themes/<?php echo get_option('wps_child_theme'); ?>/images/<?php get_custom_field('featured_img', TRUE); ?>" alt="<?php the_title(); ?>" />
								</a>
										
								<div class="featured_teaser clearfix">
									<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
									<p class="notes">in <?php the_category(', ') ?></p>
									<?php the_content('...read more'); ?>
									
									<?php if(get_post_meta($post->ID, 'new_price', true)) { 
											$values = get_post_custom_values("new_price"); 
											$new_price = $values[0]; ?>
															
												<span class="old_price"><?php get_custom_field('price', TRUE); ?></span>
												<span class="new_price"><?php get_custom_field('new_price', TRUE); ?> <span class="currency"><?php echo get_option('wps_currency_code'); ?></span></span>
											
										<?php } elseif(get_post_meta($post->ID, 'price', true)){ 
											$values 		= get_post_custom_values("price"); 
											$price 	= $values[0];?>
																
											<span class="price"><?php get_custom_field('price', TRUE); ?> <span class="currency"><?php echo get_option('wps_currency_code'); ?></span></span>
										<?php }	?>
										
										<form name="_xclick" action="" method="post">
											<input type="hidden" name="cmd" value="add" />									
											<input type="hidden" name="item_name" value="<?php the_title(); ?>" />									
											<input type="hidden" name="item_id" value="<?php get_custom_field('ID_item', TRUE); ?>"/>
											<input type="hidden" name="item_number" value="1"/>									
											<?php 
												if(get_post_meta($post->ID, 'new_price', true)) { 
													$values = get_post_custom_values("new_price"); 
													$new_price = $values[0]; ?>
												<input type="hidden" name="amount" value="<?php get_custom_field('new_price', TRUE); ?>" />
											<?php } 
												elseif(get_post_meta($post->ID, 'price', true)){ 
													$values 		= get_post_custom_values("price"); 
													$price 	= $values[0];?>
												<input type="hidden" name="amount" value="<?php get_custom_field('price', TRUE); ?>" />
											<?php }	?>									
											<input type="hidden" name="currency_code" value="<?php echo get_option('wps_currency_code'); ?>" />
											<input type="hidden" name="image_thumb" value="<?php get_custom_field('image_thumb', TRUE); ?>" />
											<input type="hidden" name="item_file" value="<?php get_custom_field('item_file', TRUE); ?>" />									
											<input type="hidden" name="add" value="1" />	
											<div class="shopform_btn">
												<input type="image" name="add" src="<?php bloginfo('wpurl'); ?>/wp-content/themes/<?php echo get_option('wps_child_theme'); ?>/images/add_to_cart.png" />								
											</div>
										</form>
									
								</div><!-- featured_teaser -->
							</div><!-- inner -->
							
							
					<?php } else { ?>
						<!--  option 2: use the item's image from custom field-->
							<div class="inner opt2 clearfix">
								<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
									<img src="<?php bloginfo('wpurl'); ?>/wp-content/themes/<?php echo get_option('wps_child_theme'); ?>/images/<?php get_custom_field('item_image', TRUE); ?>" width="272" height="342" alt="<?php the_title(); ?>" />	
								</a>
								<div class="featured_teaser clearfix">
									<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
									<p>in <?php the_category(', ') ?></p>
									<?php the_content('...read more'); ?>
									
										<?php if(get_post_meta($post->ID, 'new_price', true)) { 
											$values = get_post_custom_values("new_price"); 
											$new_price = $values[0]; ?>
															
												<span class="old_price"><?php get_custom_field('price', TRUE); ?></span>
												<span class="new_price"><?php get_custom_field('new_price', TRUE); ?> <span class="currency"><?php echo get_option('wps_currency_code'); ?></span></span>
											
										<?php } elseif(get_post_meta($post->ID, 'price', true)){ 
											$values 		= get_post_custom_values("price"); 
											$price 	= $values[0];?>
																
											<span class="price"><?php get_custom_field('price', TRUE); ?> <span class="currency"><?php echo get_option('wps_currency_code'); ?></span></span>
										<?php }	?>
										
										<form name="_xclick" target="" action="" method="post">
											<input type="hidden" name="cmd" value="add" />									
											<input type="hidden" name="item_name" value="<?php the_title(); ?>" />									
											<input type="hidden" name="item_id" value="<?php get_custom_field('ID_item', TRUE); ?>"/>
											<input type="hidden" name="item_number" value="1"/>									
											<?php 
												if(get_post_meta($post->ID, 'new_price', true)) { 
													$values = get_post_custom_values("new_price"); 
													$new_price = $values[0]; ?>
												<input type="hidden" name="amount" value="<?php get_custom_field('new_price', TRUE); ?>" />
											<?php } 
												elseif(get_post_meta($post->ID, 'price', true)){ 
													$values 		= get_post_custom_values("price"); 
													$price 	= $values[0];?>
												<input type="hidden" name="amount" value="<?php get_custom_field('price', TRUE); ?>" />
											<?php }	?>									
											<input type="hidden" name="currency_code" value="<?php echo get_option('wps_currency_code'); ?>" />
											<input type="hidden" name="image_thumb" value="<?php get_custom_field('image_thumb', TRUE); ?>" />
											<input type="hidden" name="item_file" value="<?php get_custom_field('item_file', TRUE); ?>" />									
											<input type="hidden" name="add" value="1" />								
											<div class="shopform_btn">
												<input type="image" name="add" src="<?php bloginfo('wpurl'); ?>/wp-content/themes/<?php echo get_option('wps_child_theme'); ?>/images/add_to_cart.png" />								
											</div>
										</form>	
								</div><!-- featured_teaser -->
							</div><!-- inner -->
					<?php } ?>
				<?php endwhile;?>
			</div><!-- outer -->
		</div><!-- featured_holder -->
		
		<?php include(TEMPLATEPATH.'/top_sidebar.php');  ?>	
					
		<div id="main_col" class="clearfix">
		
			<div class="col gift_vouchers">
				<h2><img src="<?php bloginfo('wpurl'); ?>/wp-content/themes/<?php echo get_option('wps_child_theme'); ?>/images/gift_voucher.png" width="80" height="52" alt="" />Gift Vouchers</h2>
				<h4>Give</h4>
				<p class="clearfix">
					<?php echo get_option('wps_give_voucher_text'); ?>
				</p>
				<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank" >
					<input type="hidden" name="cmd" value="_s-xclick" />
					<input type="hidden" name="hosted_button_id" value="<?php echo get_option('wps_button_id'); ?>" />
					<div class="giftform_btn">
						<input type="image" src="<?php bloginfo('wpurl'); ?>/wp-content/themes/<?php echo get_option('wps_child_theme'); ?>/images/<?php echo get_option('wps_button_img'); ?>" name="submit" alt="" />
						<img alt="" src="<?php bloginfo('wpurl'); ?>/wp-content/themes/<?php echo get_option('wps_child_theme'); ?>/images/<?php echo get_option('wps_button_img'); ?>" width="1" height="1" />
					</div>
				</form>
				
				<h4>Redeem</h4>
				<p>
					<?php echo get_option('wps_redeem_voucher_text'); ?>
				</p>
			
			</div><!-- col gift_vouchers -->
			
			<div class="col middle_col recently_released">
				<h2>Recently Released</h2>
				<div class="col_wrap">
					<div class="col_wrap_inner">
						<h3><a href="#">in <?php echo get_option('wps_cat1_name'); ?></a></h3>
						<?php 
						
						
						$my_query = new WP_Query('category_name='.get_option('wps_cat1_slug').'&showposts=3'); 
						
						
						?>
						<?php                                
						$counter = 0;
						while ($my_query->have_posts()) : $my_query->the_post(); 
						
						
						if($counter == 0){
						$suffix = '_first';
						}
						else {
						$suffix = NULL;
						}
						?>						
							<a class="thumb_img<?= $suffix?>" href="<?php the_permalink() ?>" title="">
								<img src="<?php bloginfo('wpurl'); ?>/wp-content/themes/<?php echo get_option('wps_child_theme'); ?>/images/<?php get_custom_field('image_thumb', TRUE); ?>" width="69" height="87" alt="<?php the_title(); ?>" />
							</a>

						<?php 
						
						$counter++;
						endwhile; ?>
					</div><!-- col_wrap_inner -->	
				</div><!-- col_wrap -->
					
					
					
					
					
					
				<div class="col_wrap">
					<div class="col_wrap_inner">
						<h3><a href="#">in <?php echo get_option('wps_cat2_name'); ?></a></h3>
						<?php $my_query = new WP_Query('category_name='.get_option('wps_cat2_slug').'&showposts=3'); ?>
						 
						<?php 
						$counter = 0;
						while ($my_query->have_posts()) : $my_query->the_post(); 
						
						
						if($counter == 0){
						$suffix = '_first';
						}
						else {
						$suffix = NULL;
						}
						?>						
							<a class="thumb_img<?= $suffix?>" href="<?php the_permalink() ?>" title="">
								<img src="<?php bloginfo('wpurl'); ?>/wp-content/themes/<?php echo get_option('wps_child_theme'); ?>/images/<?php get_custom_field('image_thumb', TRUE); ?>" width="69" height="87" alt="<?php the_title(); ?>" />
							</a>

						<?php 
						
						$counter++;
						endwhile; ?>
					</div><!-- col_wrap_inner -->		
				</div><!-- col_wrap -->
			</div><!-- recently_released -->
			
			
			
			
			<div class="col specials">
				<h2>Just Reduced</h2>
				<div class="col_wrap">
					<div class="col_wrap_inner">
						<h3><a href="#"><?php echo get_option('wps_cat3_name'); ?></a></h3>
						<?php $my_query = new WP_Query('category_name='.get_option('wps_cat3_slug').'&showposts=3'); ?>
						<?php 
						$counter = 0;
						while ($my_query->have_posts()) : $my_query->the_post(); 
						
						
						if($counter == 0){
						$suffix = '_first';
						}
						else {
						$suffix = NULL;
						}
						?>						
							<a class="thumb_img<?= $suffix?>" href="<?php the_permalink() ?>" title="">
								<img src="<?php bloginfo('wpurl'); ?>/wp-content/themes/<?php echo get_option('wps_child_theme'); ?>/images/<?php get_custom_field('image_thumb', TRUE); ?>" width="69" height="87" alt="<?php the_title(); ?>" />
							</a>

						<?php 
						
						$counter++;
						endwhile; ?>
					</div><!-- col_wrap_inner -->
				</div><!-- col_wrap -->
			</div><!-- specials -->
		</div><!-- main_col -->
		<?php 
			if (!is_home()) 
			{
				get_sidebar(); 
			}
		?>
<?php } ?>
	</div><!-- end floatswrap --> 
<?php get_footer(); ?>